[?php include_stylesheets_for_form($form) ?]
[?php include_javascripts_for_form($form) ?]

<div class="sf_admin_form">
  [?php echo form_tag_for($form, (isset($form_action)? '<?php echo $this->params['route_prefix'] ?>/'.$form_action : '@<?php echo $this->params['route_prefix'] ?>'), array('id' => 'sf_admin_edit_form', 'onsubmit' => "return disableFurtherSubmit(this)")) ?]
    [?php echo $form->renderHiddenFields() ?]

    [?php if ($form->hasGlobalErrors()): ?]
      [?php echo $form->renderGlobalErrors() ?]
    [?php endif; ?]

    [?php foreach ($configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?]
      [?php include_partial('<?php echo $this->getModuleName() ?>/form_fieldset', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset)) ?]
    [?php endforeach; ?]

    [?php include_partial('<?php echo $this->getModuleName() ?>/form_actions', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?]
  </form>
</div>

<?php if (isset($this->params['confirm_on_close']) && $this->params['confirm_on_close']): ?>
<script type="text/javascript">
//<![CDATA[
  var needs_to_confirm = true;

  window.onbeforeunload = function (event) {
    if (needs_to_confirm)
    {
      return "[?php echo __('Are you sure you want to close this window? By doing so, any unsaved work will be lost.', array(), 'sf_admin') ?]";
    }
  };
//]]>
</script>
<?php endif; ?>